import { request } from '@umijs/max';

// 分片上传
export async function chunkUploadFun(data) {
  return request(`/pan/chunkUpload`, {
    method: 'POST',
    data,
  });
}

// 获取文件列表
export async function getFileListFun(params: { fileName: string; filePid: string }) {
  return request('/pan/getFileList', {
    method: 'GET',
    params,
  });
}

// 获取用户容量
export async function getUserFileNumberFun() {
  return request('/userFileNumber/getNumber', {
    method: 'GET',
  });
}

// 新建文件夹
export async function panAddDirFun(data) {
  return request('/pan/addDir', {
    method: 'POST',
    data,
  });
}

// 删除文件
export async function deleteFileFun(data) {
  delete data.fileSize;
  return request('/pan/deleteFile', {
    method: 'POST',
    data,
  });
}

// 重命名
export async function renameFileFun(data) {
  return request('/pan/renameFileName', {
    method: 'POST',
    data,
  });
}

// 批量删除
export async function batchDeleteFun(fileIds) {
  return request('/pan/batchDelete?fileIds=' + fileIds, {
    method: 'DELETE',
  });
}

// 获取当前用户的容量
export async function getUserFileNumber(userId) {
  return request('/userFileNumber/getNumber/' + userId, {
    method: 'GET',
  });
}

// updateUserNumber
export async function updateUserNumberFun(userId, size) {
  return request('/userFileNumber/updateUserNumber?userId=' + userId + '&size=' + size, {
    method: 'POST',
  });
}
